<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test upload</title>
</head>
<body>
<form>
    <input onchange="upload()" type="file" name="file" id="file">
</form>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script type="text/javascript">
    function upload() {
        var formData = new FormData();
        formData.append("file",$('#file')[0].files[0]);
        $.ajax({
            url:'http://remote.upload.com/upload.php',
            dataType:'json',
            type:'POST',
            async: false,
            data: formData,
            processData : false, // 使数据不做处理
            contentType : false, // 不要设置Content-Type请求头
            success: function(data){
                console.log(data);
                if (data.status == 'ok') {
                    alert('上传成功！');
                }

            },
            error:function(response){
                console.log(response);
            }
        });
    }
</script>
</body>
</html>